package main

import (
	"gorm.com/lesson03_02"
	"gorm.io/driver/mysql"
	"gorm.io/gorm"
)

func InitDb(dst ...interface{}) *gorm.DB {
	db, err := gorm.Open(mysql.Open("root:root@tcp(127.0.0.1:3306)/testdb?charset=utf8mb4&parseTime=True&loc=Local"))
	if err != nil {
		panic(err)
	}
	// 初始化数据表
	db.AutoMigrate(dst...)
	return db
}

func main() {
	db, err := gorm.Open(mysql.Open("root:root@tcp(127.0.0.1:3306)/gorm?charset=utf8mb4&parseTime=True&loc=Local"))
	if err != nil {
		panic(err)
	}
	// lesson01.Run(db)
	//lesson02.Run(db)
	//lesson03.Run(db)
	lesson03_02.Run(db)
}
